home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000054_icon-group-sender _Tue Sep 2 12:02:19 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Tue, 2 Sep 1997 12:02:18 -0500 (EST)
  3. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  4.     id AA21451; Tue, 2 Sep 1997 10:02:18 -0700
  5. To: icon-group
  6. Date: 2 Sep 1997 14:20:21 GMT
  7. From: mike@stok.co.uk (Mike Stok)
  8. Message-Id: <5uh7b5$gd7@news-central.tiac.net>
  9. Organization: Pencom Systems Administration
  10. Sender: icon-group-request
  11. References: <Stuart.Robinson-0209972348010001@asianstmg-221.anu.edu.au>
  12. Subject: Re: More specific GREP-related question
  13. Errors-To: icon-group-errors
  14. Status: RO
  15.  
  16. In article <Stuart.Robinson-0209972348010001@asianstmg-221.anu.edu.au>,
  17. Stuart Robinson <Stuart.Robinson@anu.edu.au> wrote:
  18. >Does anyone know how regular expressions like [a-z] work when a
  19. >non-alphanumeric character is used?  For example, which characters would
  20. >the following regular expression match?
  21. >
  22. >[1-!]
  23.  
  24. If you actually use that in a regex on a system with ASCII encoding (or 
  25. one of the character sets wherer the low 128 characters are ASCII) you
  26. should get an "invalid [] range in regexp" warning as perl likes to work
  27. with ascending ranges.  In ASCII you're asking for a range from character
  28. 49 up to character 33
  29.  
  30. >What about this one?
  31. >
  32. >[a-1]
  33. >
  34. >And the reverse?
  35. >
  36. >[1-a]
  37.  
  38. 1-a will match a character in the range characters 49 to 97 inclusive, so
  39. in the debugger I can use perl's ord and chr functions to see what
  40. characters are in that range:
  41.  
  42.   DB<1> print ord '1'
  43. 49
  44.   DB<2> print ord 'a'
  45. 97
  46.   DB<3> print map {chr $_} (49 .. 97)
  47. 123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a
  48.  
  49. >I'm sure all of this could be predicted if one had knowledge of the
  50. >ordering of ASCII, but I'm afraid I lack such knowledge.  Any tips? 
  51.  
  52. If you're on a unix system then there is usually a manual page for ascii,
  53. so
  54.  
  55.   man ascii
  56.  
  57. should get you a useful page.  Failing that a www search or a reference
  58. book might have a table of ascii codes in it (printer manuals usually have
  59. tables of characters somewhere in them...)
  60.  
  61. Hope this helps,
  62.  
  63. Mike
  64. -- 
  65. mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
  66. http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
  67. http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
  68. stok@psa.pencom.com                |      Pencom Systems Administration (work)
  69.